<!DOCTYPE html>
<html class="js cssanimations">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>工单评价</title>
		<link rel="stylesheet" href="../assets/css/amazeui.css">
		<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="../assets/css/core.css">
		<link rel="stylesheet" href="../assets/css/menu.css">
		<link rel="stylesheet" href="../assets/css/index.css">
		<link rel="stylesheet" href="../assets/css/admin.css">
		<link rel="stylesheet" href="../assets/css/page/typography.css">
		<link rel="stylesheet" href="../assets/css/page/form.css">
	</head>
	<body onload="getData()" class="am-with-topbar-fixed-top">
		<!-- Begin page -->
		<header class="am-topbar am-topbar-fixed-top">		
			<div class="am-topbar-left am-hide-sm-only">
                <a href="../html/index.html" class="logo"><span>欢迎你</span><i class="zmdi zmdi-layers"></i></a>
            </div>
	
			<div class="contain">
				<ul class="am-nav am-navbar-nav am-navbar-left">

					<li><h4 class="page-title">取消工单</h4></li>
				</ul>
				
				<!-- <ul class="am-nav am-navbar-nav am-navbar-right">
					<li class="hidden-xs am-hide-sm-only">
                        <form role="search" class="app-search">
                            <td><button class="label label-danger" onclick='loginout()'>退出登录</span></td>
                        </form>
                    </li>
				</ul> -->
			</div>
		</header>
		<!-- end page -->
		
		
		<div class="admin">
			<!--<div class="am-g">-->
		<!-- ========== Left Sidebar Start ========== -->
		<!--<div class="left side-menu am-hide-sm-only am-u-md-1 am-padding-0">
			<div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 548px;">
				<div class="sidebar-inner slimscrollleft" style="overflow: hidden; width: auto; height: 548px;">-->
                  <!-- sidebar start -->
				  <div class="admin-sidebar am-offcanvas  am-padding-0" id="admin-offcanvas">
				    <div class="am-offcanvas-bar admin-offcanvas-bar">
				    	<!-- Handle -->
						<div class="user-box am-hide-sm-only">
	                        <div class="user-img">
	                            <img src="../assets/img/avatar-1.png" alt="user-img" title="Mat Helme" class="img-circle img-thumbnail img-responsive">
	                            <div class="user-status offline"><i class="am-icon-dot-circle-o" aria-hidden="true"></i></div>
	                        </div>
	                        <h5 id="user">admin</h5>
	                        <ul class="list-inline">
	                            <li>
	                                <a href="../html/table_basic.html#">
	                                    <i class="fa fa-cog" aria-hidden="true"></i>
	                                </a>
	                            </li>
	
	                            <li>
	                                <a href="../html/table_basic.html#" class="text-custom">
	                                    <i class="fa fa-cog" aria-hidden="true"></i>
	                                </a>
	                            </li>
	                        </ul>
	                    </div>
	                    <!-- End Handle -->
	            
						 <ul class="am-list admin-sidebar-list">
						    <li><a href="../index.html"><span class="am-icon-home"></span> 首页</a></li>
						    <li class="admin-parent">
						      <a class="am-cf" data-am-collapse="{target: &#39;#collapse-nav1&#39;}"><span class="am-icon-table"></span> 日常管理 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
						      <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav1">
						      	<li><a href="../html/table_basic.html" class="am-cf">人员管理</a></li>
						        <li><a href="../html/table_complete.html">用户管理</a></li>
						        <li><a href="../html/table_problem.html" class="am-cf"> 故障管理</a></li>
						        <li><a href="../html/table_position.html" class="am-cf"> 地址管理</a></li>
						      </ul>
						    </li>
						    <li class="admin-parent">
						      <a class="am-cf" data-am-collapse="{target: &#39;#collapse-nav5&#39;}"><span class="am-icon-file"></span> 工单模块 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
						      <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav5">
						      	<li><a href="../html/table_job.html" > 工单管理</a></li>
						        <li><a href="../html/table_evaluate.html" > 评价工单</a></li>
						        <li><a href="../html/table_cancle.html">取消工单</a></li>   
						        <li><a href="../html/form_validate.html">故障下单</a></li>
						      </ul>
						    </li>
						    <li class="admin-parent">
						      <a class="am-cf" data-am-collapse="{target: '#collapse-nav2'}"><i class="am-icon-line-chart" aria-hidden="true"></i> 统计图表 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
						      <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav2">
						        <li><a href="../html/table_perple.html" class="am-cf"> 个人统计</span></a></li>
						        <li><a href="../html/table_type.html" class="am-cf"> 总体统计</span></a></li>
						      </ul>
						    </li>
						  </ul>
				</div>
				  </div>
				  <!-- sidebar end -->
    
				<!--</div>
			</div>
		</div>-->
		<!-- ========== Left Sidebar end ========== -->
		
		
		
	<!--	<div class="am-g">-->
		<!-- ============================================================== -->
		<!-- Start right Content here -->
		<div class="content-page">
			<!-- Start content -->
			<div class="content">
				<div class="card-box">
				<!-- Row start -->
					<div class="am-g">
						<div class="am-u-sm-12 am-u-md-6">
				          <div class="am-btn-toolbar">
				            <div class="am-btn-group am-btn-group-xs">
				            	说明：取消工单只能取消未被接单的工单
				            </div>
				          </div>
				        </div>	
				    </div>
					  <!-- Row end -->
					  <!-- Row start -->
					  	<div class="am-g">
        <div class="am-u-sm-12">
          <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
              <thead>
              <tr>
                <th class="table-id">ID</th><th class="table-title">工单ID</th><th class="table-title">工单地址</th><th class="table-type">工单问题</th><th class="table-author am-hide-sm-only">创建时间</th><th class="table-date am-hide-sm-only">工单详情</th><th class="table-set">操作</th>
              </tr>
              </thead>
              <tbody id="tbody-result">
              	<!-- <tr>暂无数据</tr> -->
              </tbody>
            </table>
            
            
            <hr>
          </form>
        </div>

      </div>
					  <!-- Row end -->
					  
					</div>
				
				
				
				
				</div>
			

			</div>
		</div>
		<!-- end right Content here -->
		<!--</div>-->
		
		
		
		<!-- navbar -->
		<a href="../html/admin-offcanvas" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: &#39;#admin-offcanvas&#39;}"><!--<i class="fa fa-bars" aria-hidden="true"></i>--></a>
		
		<!-- 详情的modal窗口  开始 -->
		<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
		  <div class="am-modal-dialog">
		    <div class="am-modal-hd"><h1>工单详情</h1> 
		      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close="">×</a>
		    </div>
		    <div class="am-form-group">
		      	<div class="am-form-group">
				  <label for="doc-vld-name_id-2">工 &nbsp单 &nbspID：</label>
				  <input type="text" id="m_job_id" disabled="disabled">
				</div>
				
				<div class="am-form-group">
				  <label for="doc-vld-url-2"> 工单地址：</label>
				  <input type="text" id="m_position" disabled="disabled">
				</div>
				<div class="am-form-group">
				  <label for="doc-vld-email-2">工单问题：</label>
				  <input type="text" id="m_problem" disabled="disabled">
				</div>
				
				
				<div class="am-form-group">
				  <label for="doc-vld-age-2">下单时间：</label>
				  <input type="text" id="m_createtime" disabled="disabled">
				</div>
				
				<div class="am-form-group">
				  <label for="doc-vld-age-2"> 工单详情：</label>
				  <input type="text" id="m_detail" disabled="disabled">
				</div>
				<button type="button" class="am-btn am-btn-primary btn-loading-example" onclick="closeModal()">确定</button>
		    </div>
		  </div>
		</div>
		<!-- 详情的modal窗口  结束 -->
		
		
		
		
		<script type="text/javascript" src="../assets/js/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../assets/js/amazeui.min.js"></script>
		<script type="text/javascript" src="../assets/js/app.js"></script>
		<script type="text/javascript" src="../assets/js/blockUI.js"></script>
		<script>
		
		
		var getData = function(){	
			$.ajax({
				 type : "POST", //提交方式 
			     url : "../Job/cancelList",//路径 
			     contentType : "application/json;charset=UTF-8",
			     dataType:"Json",
			     async:true,
			     success : function(res) {//返回数据根据结果进行相应的处理 
			    	 if (res) {  
			    		 console.log(res)
		                 var data = res.object; 
		                 var str = '';
		                 for (var i = 0, len = data.length; i < len; i++) {
		                	 if(data[i].detail==null){
		                		 data[i].detail=''
		                	 }
		                	 str += '<tr class="item" data-number="i"><td class="item-number">' + (i+1) + '</td>';
							 str += '<td><a href="#">' + data[i].job_id + '</a></td>';
							 str += '<td class="item-name">' + data[i].position + '</td>';
							 str += '<td class="am-hide-sm-only">' + data[i].problem + '</td>';
							 str += '<td class="am-hide-sm-only">' + data[i].create_time + '</td>';
							 str += '<td class="am-hide-sm-only">' + data[i].detail + '</td>';
							 str += '<td><div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button  class="am-btn am-btn-default am-btn-xs am-text-secondary detail-btn" data-name="' + data[i].job_id + '"><span class="am-icon-pencil-square-o"></span> 详情</button>';
		                     str += '<button class="am-btn am-btn-default am-btn-xs am-hide-sm-only cancel-btn" data-name="' + data[i].job_id + '"><span class="am-icon-copy"></span> 取消</button></div></div></td></tr>';
		                 }	
		                 $("#tbody-result").html(str)		                 
		                 $("#tbody-result").off("click").on("click",function(event) {
		                	 event.preventDefault()
							 if($(event.target).hasClass("detail-btn")){
								 $('#doc-modal-1').modal();
								 var job_id = $(event.target).attr("data-name");
								 $.ajax({
									 type:"POST",
									 url:"../Job/getJobById",
									 data:{job_id:job_id},
								     dataType:"Json",
								 	 success:function(res){
								 		 console.log(res);
								 		 var data = res.object;
								 		 $("#m_job_id").val(data.job_id);
								 		 $("#m_problem").val(data.problem);
								 		 $("#m_position").val(data.position);
								 		 $("#m_createtime").val(data.create_time);
								 		 $("#m_detail").val(data.detail);
								 	 }
								});
		                	 }else if($(event.target).hasClass("cancel-btn")){
		                		 if(event.target)
				                	 var r=confirm("确定取消订单？")
		                		 if (r==true){
		                			 var job_id = $(event.target).attr("data-name");
		                			 $.ajax({
			                	    		type : "POST", //提交方式
			                	    		url:"../Job/delectJob",
			                	    		data:{job_id:job_id},
			               			    	dataType:"json",
			               			     	success : function(res){
			               			     		alert("取消成功！");
			                               		window.location.reload();
			               			     	}
			                	    	});
		                		 }
		                	 }
		                	
		                 });
			    	 }      
		        },  
		    }); }
			
		var closeModal = function(){
			$('#doc-modal-1').modal('close');
		}
		
		
		
		var closeaddModal = function(){
			$('#doc-modal-2').modal('close');
		}
		
		var addEvaluate = function(){
			var job_id=$("#m2_jobid").val();
			var evaluate_level=$("#m2_evaluatelevel").val();
			var evaluate_detial=$("#m2_evaluatedetail").val();
			$.ajax({
				type:"POST",
				url:"../Job/evaluateJob",
				data:{job_id:job_id,evaluate_level:evaluate_level,evaluate_detial:evaluate_detial},
			    dataType:"Json",
			 	success:function(res){
			 		if(res.info == "success"){
			 			$('#doc-modal-2').modal('close');
			 			alert("评价成功")
			 			window.location.href = "table_evaluate.html"
			 		}
			 	}
			})
		}
		
		//获得当前用户
		$.ajax({
			type:"post",
			url : "../User/getUser",//路径 
		    contentType : "application/json;charset=UTF-8",
		    dataType:"Json",
		    async:true,
		    success : function(res){
		    	if(res.info == "success"){
		    		var data = res.object;
		    		$("#user").html(data.real_name)
		    	}else{
		    		window.location.href = "../login.jsp" 
		    	}
		    }
		})
		
		var loginout = function(){
			var num = 1;
			$.ajax({
				type:"post",
				url : "login/loginout",//路径 
				contentType : "application/json;charset=UTF-8",
			    data:{num:num},
			    dataType:"Json",
			    success : function(res){
			    	
			    	if(res.info == "success"){
			    		console.log(res.info) 
			    	}
			    }
			})
		}
		</script>
	
	
	
	

</body></html>